/// <reference path="jquery.js" />
/// <reference path="Verification.js" />

/* 投稿专用JS */
function IssuedAdd() {
    var item_lang = GetVal("lang", 1);
    var Item_User_Name = $("#Item_User_Name").val();
    var Item_User_Id = $("#Item_User_Id").val();
    var Item_User_Email = $("#Item_User_Email").val();
    var Item_User_Tel = $("#Item_User_Tel").val();
    var Item_Column = $("#Typ1_0").val();
    var Item_Text = editor.html();
    var Item_Title = $("#Item_Title").val();
	var Item_Summary=$("#Item_Summary").val();
	var VerificationImgCode=$("#VerificationImgCode").val();

	
    /* 验证用户名长度 */
	if (item_lang == 1)
	    if (!ValidateReg("Item_User_Name", ValidateUyghurName))
	        return false;
	    else
	        if (!ValidateLength("Item_User_Name", 2, 60))
	            return false;
    /* 身份证 */
    if (!ValidateReg("Item_User_Id", ValidateUserId))
    return false;
    /* 验证联系号码 */
    if (!ValidateReg("Item_User_Tel", ValidatePhone))
    return false;
    /* 验证邮箱 */
    if (!ValidateReg("Item_User_Email", ValidateEmail))
    return false;
	/* 验证是否已选栏目ID */
 	if (!ValidateSelect("Typ1_0"))
	return false;
    /* 验证标题 */
    if (!ValidateLength("Item_Title", 3,320))
	return false;
	/* 验证标题 */
    if (!ValidateLength("Item_Summary", 60,320))
        return false;
    if (!ValidateLength("VerificationImgCode", 5, 6))
        return false;
	


    jQuery.ajax({
        url: "../ajax/Issued-Add.ashx",
        type: "post",
        cache: "false",
        data: {
             "Item_User_Name": Item_User_Name,
             "Item_User_Id": Item_User_Id,
             "Item_User_Email": Item_User_Email,
             "Item_User_Tel": Item_User_Tel,
             "Item_Column": Item_Column,
             "Item_Text": Item_Text,
             "Item_Title": Item_Title,
			 "VerificationImgCode":VerificationImgCode,
			 "Item_Summary": Item_Summary,
			 "item_lang": item_lang

        },
        dataType: "text",
        beforeSend: function() {$("#Verification-Code").slideUp()},
        success: function(msg) {
            $("#Verification-Code").slideDown();

            if (msg == "1")
                window.location.href = "Complete.aspx?for=issued";
            else {
                alert(Lang_Error + "\n" + msg);
                ImgCodeReplace();
            }
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert("错误代码：" + XMLHttpRequest.status + " , 错误类型 ： " + XMLHttpRequest.readyState + " , 错误文本：" + textStatus);
        },
        complete: function() {}

    });


}

function BlurValidate() {
    $("#Item_User_Name").blur(function() {
        ValidateReg("Item_User_Name", ValidateUyghurName)
    });
    $("#Item_User_Id").blur(function() {
        ValidateReg("Item_User_Id", ValidateUserId)
    });
    $("#Item_User_Tel").blur(function() {
        ValidateReg("Item_User_Tel", ValidatePhone)
    });
    $("#Item_User_Email").blur(function() {
        ValidateReg("Item_User_Email", ValidateEmail)
    });
    $("#Item_Title").blur(function() {
        ValidateLength("Item_Title", 3,80)
    });
	$("#Item_Summary").blur(function() {
        ValidateLength("Item_Summary", 60,320)
    });
	$("#Typ1_0").change(function() {
        ValidateSelect("Typ1_0")
    });

}